﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using 新门禁.Utils;

namespace 新门禁
{
    /// <summary>
    /// CheckWindow.xaml 的交互逻辑
    /// </summary>
    public partial class CheckWindow : Window
    {
         string billId = "";
        public CheckWindow()
        {
            InitializeComponent();
        }

        public void setBillNo(String billId)
        {
            this.billId = billId;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (txtMemo.Text.Trim().Length < 2)
            {
                MessageBox.Show("请输入安检通过原因");
                return;
            }
            try
            {
                String ip = App.GetBaseInfo().HttpServerIp;
                String port = App.GetBaseInfo().HttpServerPort;
              

                    JObject reqJSON = new JObject();
                    reqJSON.Add("billId", billId);
                    reqJSON.Add("checkMsg", txtMemo.Text);
               
                
                //String bodyJsonStr = "{\"gateCode\":\"" + gateCode + "\", \"carNo\":\"" + carno + "\", \"type\":\"" + inOutType + "\"}";

                String result = HttpPostHelper.doHttpPost("http://" + ip + ":" + port + "/qd-s-factory/clientApi/checkCarAdmin", reqJSON.ToString());
                JObject resJSON = JObject.Parse(result);
                string status = (string)resJSON.GetValue("code");
                string message = (string)resJSON.GetValue("message");
                if ("00000".Equals(status))
                {
                   
                    this.DialogResult = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        }

        private void Button_Click_Close(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
